
$(function () {
    $("div.data-main").each(function(){
        let width = $(this).parent("div.data-width").width();
        $(this).css("width",width+"px");
    })
    //获取养老机构编号
    var pensionNo = $(".layui-this").attr("data-pension");
    changePensionData(pensionNo);
})
function changePensionData(pensionNo) {
    //获取床位统计信息
    queryBedStatisticInfo(pensionNo);
    //查询老人信息统计
    queryManDataInfo(pensionNo);
    //查询账务统计数据
    //获取当前年份和月份
    var date=new Date;
    var year=date.getFullYear();
    var month=date.getMonth()+1;
    if(month<10){
        month="0"+month;
    }
    $("#selectYear").html(year+"-"+month);
    layui.use(['element', 'laydate', 'layer','carousel'], function() {
        var carousel = layui.carousel;
        var laydate = layui.laydate;
        //}
        carousel.render({
            elem: '#slide1'
            ,width: '' //设置容器宽度
            ,height: '250px'
            ,arrow: 'always' //始终显示箭头
            //,anim: 'updown' //切换动画方式
            ,indicator: 'none'
            ,autoplay: false
        });
        carousel.render({
            elem: '#slide2'
            ,width: '' //设置容器宽度
            ,height: '250px'
            ,arrow: 'always' //始终显示箭头
            //,anim: 'updown' //切换动画方式
            ,indicator: 'none'
            ,autoplay: false
        });
        laydate.render({
            elem: '#test-month',
            type: 'month',
            position: 'static'
            ,done: function(value, date){
                if(value!=''){
                    $("#selectYear").html(value);
                    var year = date.year;
                    var month = date.month;
                    if(month<10){
                        month = "0"+month;
                    }
                    var pensionNo=$("#pensionNo").val();
                    queryPensionFeeData(pensionNo,year,month);
                }
                $('.money-time-art').slideToggle(300);
            }
        });
        laydate.render({
            elem: '#test-year',
            type: 'year',
            position: 'static'
            ,done: function(value, date){
                if(value!=''){
                    $("#selectYear").html(value);
                    var pensionNo=$("#pensionNo").val();
                    queryPensionFeeData(pensionNo,value,"");
                }
                $('.money-time-art').slideToggle(300);
            }
        });
    });
    $('.money-time-select').click(function(){
        $('.money-time-art').slideToggle(300);
    })
    queryPensionFeeData(pensionNo,year,month);
}
//获取床位统计信息
function queryBedStatisticInfo(pensionNo){
    $.ajax({
        url:getRootPath_web()+'statistics/obtainBedStatisticData',
        type:'post',
        dataType:'json',
        data:{"pensionNo":pensionNo},
        success:function (result) {
            if(result.code=='0000'){
                //总床位数
                $("#totalBedCount").html(result.totalBedCount);
                //总人数
                $("#totalUserCount").html(result.totalUserCount);
                //空置床位数
                $("#emptyBedCount").html(result.emptyBedCount);
                //入住率
                $("#pensionRate").html(result.pensionRate);
                $("#pensionBuilding").empty();

                if(result.buildingCount>0){
                    $.each(result.buildingInfo,function (key,b) {
                        var str="";
                        str+="<li>";
                        str+="<article class=\"border-radius4 border1px-ddd\">";
                        str+="<div class=\"overflow title-two-con pad20px\">";
                        str+="<span class=\"left f16px fb\">"+b.buildingName+"</span>";
                        str+="<span id='"+b.buildingNo+"' onclick='obtainBuildingInfoDetail(this)' class=\"right f14px cursor\">查看分布图";
                        str+="<img src='"+getRootPath_web()+"static/img/icon_right_arrow.png' alt=\"\">";
                        str+="</span>";
                        str+="</div>";
                        str+="<div class=\"data-width\">";
                        str+="<div id='dataContent"+b.buildingNo+"'style=\"width: 100%; height: 180px;\"></div>";
                        str+="</div>";
                        str+="</article>";
                        str+="</li>";
                        $("#pensionBuilding").append(str);
                        //加载图片数据
                        loadingBuildingDate('dataContent'+b.buildingNo,b.usedBed,b.totalBed);
                    })
                }else {
                    var emptyStr="";
                    emptyStr+="<div>暂无数据信息</div>";
                    $("#pensionBuilding").append(emptyStr);
                }

            }
        }
    })
}
//加载楼苑统计数据
function loadingBuildingDate(id,usedBed,totalBed){
    var myChart = echarts.init(document.getElementById(id));
    var option = {
        color: ['#FFCF76', '#1C9399'],
        legend: {
            selectedMode: false, //取消图例上的点击事件
            orient: 'vertical',
            right: '0',
            y: 'center',
            itemWidth: 10,
            itemHeight: 10,
            itemGap: 5, //图例之间的间距
            textStyle: {
                color: '#333',
                fontSize: 12,
                padding: [3, 0, 0, 10]
            },
        },
        color: ['#FFCF76', '#1C9399'],
        series: [{
            name: '',
            type: 'pie',
            // 饼图的半径，数组的第一项是内半径，第二项是外半径
            radius: ['90px', '65px'],
            // 是否启用防止标签重叠策略
            avoidLabelOverlap: false,
            hoverAnimation: false,
            // 标签的视觉引导线样式，在 label 位置 设置为'outside'的时候会显示视觉引导线
            labelLine: {
                normal: {
                    show: false
                }
            },
            data: [{
                value: usedBed,
                label: {
                    normal: {
                        // 是显示标签
                        show: true,
                        position: 'center',
                        fontSize: 14,
                        fontWeight: 'bold',
                        //formatter: ['{c}','{d}'].join('\n'),
                        formatter: ['入住：' +'{c}' , '入住率：' + '{d}' + '%'].join('\n\n'),
                        textStyle: { //图例文字的样式
                            color: '#333',
                            fontSize: 14,
                        },
                    },
                },
            },
                {
                    value: totalBed,
                    label: {
                        normal: {
                            show: false,

                        }
                    },
                    itemStyle: {
                        normal: {
                            color: '#1C9399'
                        }, //正常颜色
                        emphasis: {
                            color: '#1C9399'
                        }, //鼠标移入颜色
                    },
                },

            ]
        }]
    };
    myChart.setOption(option);
    $("div#"+id).css("width","auto");
    $(window).resize(function() {
        myChart.resize();
    });
}
//查询老人信息统计
function queryManDataInfo(pensionNo){
    $.ajax({
        url:getRootPath_web()+'statistics/obtainManStatisticData',
        type:'post',
        dataType:'json',
        data:{"pensionNo":pensionNo},
        success:function (result) {
            if(result.code=='0000'){
                //总服务人数
                $("#historyOldMan").html(result.historyOldMan);
                //当前养老院人数
                $("#currentOldMan").html(result.currentOldMan);
                //性别统计
                sexDataInfo(result.manCount,result.woManCount);
                //文化程度统计
                var educationData=[];
                $.each(result.eductionData,function (key,e) {
                    var tempData = {};
                    var value = e.manCount;
                    var name = e.label_name;
                    tempData['value']=value;
                    tempData['name']=name;
                    educationData.push(tempData);
                })
                educationDateInfo(educationData);
                //社保类型统计
                var socialInsurance=[];
                $.each(result.socialInsuranceData,function (key,e) {
                    var tempData = {};
                    var value = e.manCount;
                    var name = e.label_name;
                    tempData['value']=value;
                    tempData['name']=name;
                    socialInsurance.push(tempData);
                })
                socialInsuranceDataInfo(socialInsurance);
                //护理等级统计
                var nursingDegree=[];
                var nursingCount=[];
                $.each(result.nursingData,function (key,e) {
                    var value = e.man_count;
                    var name = e.COST_NAME;
                    nursingDegree.push(name);
                    nursingCount.push(value);
                })
                nursingDegreeDataInfo(result.nursingInterval.max,result.nursingInterval.interval,nursingDegree,nursingCount);
                //长护险等级数据统计
                var assessmentDegree=[];
                var assessmentCount=[];
                $.each(result.assessmentData,function (key,e) {
                    var value = e.man_count;
                    var name = e.COST_NAME;
                    assessmentDegree.push(name);
                    assessmentCount.push(value);
                })
                assessmentDegreeInfo(result.assessmentInterval.max,result.assessmentInterval.interval,assessmentDegree,assessmentCount);
                //年龄统计信息
                var man=[];
                var woman=[];
                $.each(result.ageOfMan,function (key,e) {
                    var value = e.AGE_COUNT;
                    man.push(-value);
                })
                $.each(result.ageOfWoman,function (key,e) {
                    var value = e.AGE_COUNT;
                    woman.push(value);
                })
                ageDataInfo(man,woman);
            }
        }
    })
}
//填充年龄统计数据信息
function sexDataInfo(man,woman){
    //获取性别统计数据
    var myChart = echarts.init(document.getElementById('sexDataContent'));
    var option = {
        color: ['#EB7E65', '#1C9399'],
        legend: {
            selectedMode: false, //取消图例上的点击事件
            orient: 'vertical',
            right: '30',
            y: 'center',
            itemWidth: 8,
            itemHeight: 8,
            itemGap: 10, //图例之间的间距
            textStyle: {
                color: '#333',
                fontSize: 12,
                padding: [4, 0, 0, 10]
            },
        },
        series: [{
            name: '',
            type: 'pie',
            radius: 80,
            center: ['48%', 'center'],
            avoidLabelOverlap: false,
            //hoverAnimation:false,   //  防止点击变大事件

            itemStyle: {
                normal: {
                    label: {
                        show: true,
                        formatter: "{c}",
                        textStyle: {
                            color: '#333'
                        },
                        padding: [0, 0], //文字和图的边距
                        rich: {
                            b: { //value 文字样式
                                fontSize: 12,
                                lineHeight: 60,
                                align: 'center',
                                color: '#333'
                            },
                        }
                    },
                    show: true,
                    borderColor: '#fff',
                    borderWidth: 1,
                },
            },


            data: [{
                value: man,
                name: '男'
            },
                {
                    value: woman,
                    name: '女',
                }
            ],
        }],
    };
    myChart.setOption(option);
    $("div#sexDataContent").css("width","auto");
    $(window).resize(function() {
        myChart.resize();
    });
    // 默认高亮
    let index = 0; // 高亮索引
    myChart.dispatchAction({
        type: "highlight",
        seriesIndex: index,
        dataIndex: index
    });
    myChart.on("mouseover", function(e) {
        if (e.dataIndex != index) {
            myChart.dispatchAction({
                type: "downplay",
                seriesIndex: 0,
                dataIndex: index
            });
        }
    });
    myChart.on("mouseout", function(e) {
        index = e.dataIndex;
        myChart.dispatchAction({
            type: "highlight",
            seriesIndex: 0,
            dataIndex: e.dataIndex
        });
    });
}
//填充文化程度统计数据
function educationDateInfo(educationData){
    var myChart = echarts.init(document.getElementById('educationDataContent'));
    var option = {
        color: ['#42C3AF', '#EB7E65','#73A0FA', '#A285D2','#83D0EF', '#1C9399','#F7C739','#AAEEFF'],
        legend: {
            selectedMode: false, //取消图例上的点击事件
            orient: 'vertical',
            right: '30',
            y: 'center',
            itemWidth: 8,
            itemHeight: 8,
            itemGap: 9, //图例之间的间距
            textStyle: {
                color: '#333',
                fontSize: 12,
                padding: [4, 0, 0, 10]
            },
        },
        series: [{
            name: '',
            type: 'pie',
            radius: 70,
            center: ['45%', 'center'],
            avoidLabelOverlap: false,
            //hoverAnimation:false,   //  防止点击变大事件

            itemStyle: {
                normal: {
                    label: {
                        show: true,
                        formatter: "{c}",
                        textStyle: {
                            color: '#333'
                        },
                        padding: [0, 0], //文字和图的边距
                        rich: {
                            b: { //value 文字样式
                                fontSize: 12,
                                lineHeight: 60,
                                align: 'center',
                                color: '#333'
                            },
                        }
                    },
                    show: true,
                    borderColor: '#fff',
                    borderWidth: 1,
                },
            },
            data: educationData,
        }],
    };
    myChart.setOption(option);
    $("div#educationDataContent").css("width","auto");
    $(window).resize(function() {
        myChart.resize();
    });
}
//填充社保类型数据
function socialInsuranceDataInfo(socialInsurance){
    var myChart = echarts.init(document.getElementById('socialInsuranceDataContent'));
    var option = {
        color: ['#42C3AF', '#EB7E65','#73A0FA', '#A285D2','#83D0EF', '#1C9399','#F7C739'],
        legend: {
            selectedMode: false, //取消图例上的点击事件
            orient: 'vertical',
            right: '30',
            y: 'center',
            itemWidth: 8,
            itemHeight: 8,
            itemGap: 9, //图例之间的间距
            textStyle: {
                color: '#333',
                fontSize: 12,
                padding: [4, 0, 0, 10]
            },
        },
        series: [{
            name: '',
            type: 'pie',
            radius: [70,40],
            center: ['40%', 'center'],
            avoidLabelOverlap: false,
            hoverAnimation:false,   //  防止点击变大事件
            labelLine: {
                normal: {
                    length: 40, // 改变标示线的长度
                    length2: 10,
                },
            },
            itemStyle: {
                normal: {
                    label: {
                        show: true,
                        formatter: "{c}",
                        textStyle: {
                            color: '#333'
                        },
                        padding: [0, 0], //文字和图的边距
                        rich: {
                            b: { //value 文字样式
                                fontSize: 12,
                                lineHeight: 60,
                                align: 'center',
                                color: '#333'
                            },
                        }
                    },
                    show: true,
                    borderColor: '#fff',
                    borderWidth: 1,
                },
            },
            data: socialInsurance,
        }],
    };
    myChart.setOption(option);
    $("div#socialInsuranceDataContent").css("width","auto");
    $(window).resize(function() {
        myChart.resize();
    });
}
//填充护理等级数据信息
function nursingDegreeDataInfo(max,interval,nursingDegree,nursingCount){
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('nursingDataContent'));
    // 指定图表的配置项和数据
    var option = {
        grid: {
            top:'30',
            left: '0',   //图表距边框的距离
            right: '0',
            bottom: '0',
            containLabel: true
        },
        xAxis: {
            type: 'category',
            /*boundaryGap: false,*/

            axisLabel: {
                textStyle: {
                    color:'#333',
                    fontSize: 12,
                },
            },
            axisTick:{
                show:false  //去掉y轴刻度线
            },

            //坐标轴颜色
            axisLine:{
                show:false
            },
            data: nursingDegree
        },
        yAxis: [
            {
                type: 'value',
                min:0,
                max:max,
                interval:interval,
                splitLine: {
                    show: true ,
                    lineStyle: {
                        color: 'rgba(0, 0, 0, 0.15)',
                        width: '1'
                    }
                },
                axisLabel: {
                    textStyle: {
                        color:'#333',
                        fontSize: 12,
                    },

                },

                axisTick:{
                    show:false  //去掉y轴刻度线
                },
                //坐标轴颜色
                axisLine:{
                    show:false,
                    lineStyle:{
                        color:'#rgba(0, 0, 0, 0.15)',
                        width:'1'
                    }
                },
            }
        ],
        series: [{
            name:'',
            type:'bar',
            barWidth: '50',
            itemStyle : {
                normal : {
                    barBorderRadius:[2, 2, 0, 0],
                    label: {
                        show: true,//是否展示
                        position: 'top',
                        textStyle: {
                            fontSize: 14,
                            color:'#333',
                        }
                    },
                    color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
                        offset: 1,
                        color: '#1C9399'
                    }, {
                        offset: 0.3,
                        color: '#3CC5C9'
                    }]),
                }
            },
            data:nursingCount
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
    $("div#nursingDataContent").css("width","auto");
    $(window).resize(function() {
        myChart.resize();
    });
}
//填充长护险统计数据
function assessmentDegreeInfo(max,interval,assessmentDegree,assessmentCount){
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('assessmentDataContent'));
    // 指定图表的配置项和数据
    var option = {
        grid: {
            top:'30',
            left: '0',   //图表距边框的距离
            right: '0',
            bottom: '0',
            containLabel: true
        },
        xAxis: {
            type: 'category',
            /*boundaryGap: false,*/

            axisLabel: {
                textStyle: {
                    color:'#333',
                    fontSize: 12,
                },
            },
            axisTick:{
                show:false  //去掉y轴刻度线
            },

            //坐标轴颜色
            axisLine:{
                show:false
            },
            data: assessmentDegree
        },
        yAxis: [
            {
                type: 'value',
                min:0,
                max:max,
                interval:interval,
                splitLine: {
                    show: true ,
                    lineStyle: {
                        color: 'rgba(0, 0, 0, 0.15)',
                        width: '1'
                    }
                },
                axisLabel: {
                    textStyle: {
                        color:'#333',
                        fontSize: 12,
                    },

                },

                axisTick:{
                    show:false  //去掉y轴刻度线
                },
                //坐标轴颜色
                axisLine:{
                    show:false,
                    lineStyle:{
                        color:'#rgba(0, 0, 0, 0.15)',
                        width:'1'
                    }
                },
            }
        ],
        series: [{
            name:'',
            type:'bar',
            barWidth: '50',
            itemStyle : {
                normal : {
                    barBorderRadius:[2, 2, 0, 0],
                    label: {
                        show: true,//是否展示
                        position: 'top',
                        textStyle: {
                            fontSize: 14,
                            color:'#333',
                        }
                    },
                    color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
                        offset: 1,
                        color: '#1C9399'
                    }, {
                        offset: 0.3,
                        color: '#3CC5C9'
                    }]),
                }
            },
            data:assessmentCount
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
    $("div#assessmentDataContent").css("width","auto");
    $(window).resize(function() {
        myChart.resize();
    });
}
//填充年龄数据信息
function ageDataInfo(man,woman){
    //男性
    // 基于准备好的dom，初始化echarts实例
    var myChartMan = echarts.init(document.getElementById('manDataContent'));
    // 指定图表的配置项和数据
    var option = {
        grid: {
            top: '0',
            left: '30', //图表距边框的距离
            right: '0',
            bottom: '0',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            /*boundaryGap: [0, 0.01],*/
            axisTick: {
                show: false //去掉y轴刻度线
            },
            splitLine: {
                show: false
            },
            axisLine: {
                show: false
            },
            axisLabel: {
                show: false
            },
        },
        yAxis: {
            type: 'category',
            data: ['60岁以下','60-64岁', '65-69岁', '70-74岁', '75-79岁','80-84岁', '85-89岁', '90-94岁', '95-99岁','100岁及以上'],
            axisTick: {
                show: false //去掉y轴刻度线
            },
            axisLine: {
                show: false
            },
            axisLabel: {
                show: false
            },
        },
        series: [{
            type: 'bar',
            barWidth: '12',
            showBackground: false,
            itemStyle: {
                normal: {
                    barBorderRadius: [6, 6, 6, 6],
                    label: {
                        show: true, //是否展示
                        position: 'left',
                        textStyle: {
                            fontSize: 12,
                            color: '#333',
                        },
                        formatter: function (value) {
                            if(value.data<0){
                                return -value.data;
                            }
                        },
                    },
                    color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
                        offset: 0,
                        color: '#3CC5C9'
                    }, {
                        offset: 1,
                        color: '#1C9399'
                    }]),
                }
            },
            data: man,
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChartMan.setOption(option);
    $("div#manDataContent").css("width","auto");
    $(window).resize(function() {
        myChartMan.resize();
    });

    // 基于准备好的dom，初始化echarts实例
    var myChartWoman = echarts.init(document.getElementById('womanDataContent'));
    // 指定图表的配置项和数据
    var option = {
        grid: {
            top: '0',
            left: '0', //图表距边框的距离
            right: '30',
            bottom: '0',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            /*boundaryGap: [0, 0.01],*/
            axisTick: {
                show: false //去掉y轴刻度线
            },
            splitLine: {
                show: false
            },
            axisLine: {
                show: false
            },
            axisLabel: {
                show: false
            },
        },
        yAxis: {
            type: 'category',
            data: ['60岁以下','60-64岁', '65-69岁', '70-74岁', '75-79岁','80-84岁', '85-89岁', '90-94岁', '95-99岁','100岁及以上'],
            axisTick: {
                show: false //去掉y轴刻度线
            },
            axisLine: {
                show: false
            },
            axisLabel: {
                show: false
            },
        },
        series: [{
            type: 'bar',
            barWidth: '12',
            showBackground: false,
            itemStyle: {
                normal: {
                    barBorderRadius: [6, 6, 6, 6],
                    label: {
                        show: true, //是否展示
                        position: 'right',
                        textStyle: {
                            fontSize: 12,
                            color: '#333',
                        }
                    },
                    color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                        offset: 0,
                        color: '#FDA095'
                    }, {
                        offset: 1,
                        color: '#FA675C'
                    }]),
                }
            },
            data:woman,
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChartWoman.setOption(option);
    $("div#womanDataContent").css("width","auto");
    $(window).resize(function() {
        myChartWoman.resize();
    });
}
//查询账务管理统计信息
function queryPensionFeeData(pensionNo,year,month){
    $.ajax({
        url:getRootPath_web()+'statistics/obtainPensionFeeStatisticData',
        type:'post',
        dataType:'json',
        data:{"pensionNo":pensionNo,"year":year,"month":month},
        success:function (result) {
            if(result.code=='0000'){
                //总费用
                $("#TOTAL_FEE").html(result.billInfo.TOTAL_FEE);
                //总伙食费
                $("#MEAL_FEE").html(result.billInfo.MEAL_FEE);
                //总床位费
                $("#BED_FEE").html(result.billInfo.BED_FEE);
                //总护理费
                $("#NURSING_FEE").html(result.billInfo.NURSING_FEE);
                //总长护险补贴
                $("#ASSESSMENT_FEE").html(result.billInfo.ASSESSMENT_FEE);
                //总其他费用
                $("#SPECIAL_FEE").html(result.billInfo.SPECIAL_FEE);
                //总交纳费用
                $("#totalPaymentAmount").html(result.totalPaymentAmount);
            }
        }
    })
    // //按月份获取当前月份的缴费统计信息
    if(month!=''){
        obtainPaymentStatisticDataByDay(pensionNo,year,month);
    }else {
        obtainPaymentStatisticDataByMonth(pensionNo,year);
    }
    //获取欠费人员信息列表
    obtainOwningPayUserDataInfo(pensionNo,7);
}
//按天获取缴费统计信息
function obtainPaymentStatisticDataByDay(pensionNo,year,month){
    $.ajax({
        url:getRootPath_web()+'statistics/obtainPaymentStatisticDataByDay',
        type:'post',
        dataType:'json',
        data:{"pensionNo":pensionNo,"year":year,"month":month},
        success:function (result) {
            if(result.code=='0000'){
                $("#paymentFeeContent").empty();
                var dataContent = "<div id='dayDataContent' style=\"width: 100%; height: 220px;\"></div>";
                $("#paymentFeeContent").append(dataContent);
                var dateStr=[];
                var feeCountStr=[];
                $.each(result.array,function (key,f) {
                    dateStr.push(f.day);
                    feeCountStr.push(f.dayAmount);
                })
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('dayDataContent'));
                // 指定图表的配置项和数据
                var option = {
                    grid: {
                        top:'20',
                        left: '0',   //图表距边框的距离
                        right: '0',
                        bottom: '0',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'category',
                        /*boundaryGap: false,*/

                        axisLabel: {
                            textStyle: {
                                color:'#333',
                                fontSize: 12,
                            },
                        },
                        axisTick:{
                            show:false  //去掉y轴刻度线
                        },

                        //坐标轴颜色
                        axisLine:{
                            show:true,
                            lineStyle: {
                                color: 'rgba(0, 0, 0, 0.45)',
                                width: '1'
                            }
                        },
                        data: dateStr
                    },
                    yAxis: [
                        {
                            type: 'value',
                            min:0,
                            max:result.intervalData.max,
                            interval:result.intervalData.interval,
                            splitLine: {
                                show: true ,
                                lineStyle: {
                                    color: '#eee',
                                    width: '1'
                                }
                            },
                            axisLabel: {
                                textStyle: {
                                    color:'#333',
                                    fontSize: 12,
                                },

                            },

                            axisTick:{
                                show:false  //去掉y轴刻度线
                            },
                            //坐标轴颜色
                            axisLine:{
                                show:false,
                            },
                        }
                    ],
                    series: [
                        {
                            name:'',
                            type:'line',
                            itemStyle : {
                                normal : {
                                    barBorderRadius:[2, 2, 0, 0],
                                    label: {
                                        show: true,//是否展示
                                        position: 'top',
                                        textStyle: {
                                            fontSize: 12,
                                            color:'#333',
                                        }
                                    },
                                    color: 'rgba(28, 148, 154, 1)'
                                },

                            },
                            areaStyle: {
                                normal: {
                                    //前四个参数代表位置 左下右上，如下表示从上往下渐变色 紫色到暗蓝色，
                                    color: new echarts.graphic.LinearGradient(
                                        0, 0, 0, 1,
                                        [
                                            { offset: 0, color: 'rgba(28, 148, 154, 1)' },
                                            { offset: 1, color: 'rgba(28, 148, 154, 0)' }
                                        ]
                                    )
                                }
                            },

                            data: feeCountStr
                        },]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
                $("div#dayDataContent").css("width","auto");
                $(window).resize(function() {
                    myChart.resize();
                });
            }
        }
    })
}
//按月获取缴费统计信息
function obtainPaymentStatisticDataByMonth(pensionNo,year){
    $.ajax({
        url:getRootPath_web()+'statistics/obtainPaymentStatisticDataByMonth',
        type:'post',
        dataType:'json',
        data:{"pensionNo":pensionNo,"year":year},
        success:function (result) {
            if(result.code=='0000'){
                $("#paymentFeeContent").empty();
                var dataContent = "<div id='monthDataContent' style=\"width: 100%; height: 220px;\"></div>";
                $("#paymentFeeContent").append(dataContent);
                var dateStr=[];
                var feeCountStr=[];
                $.each(result.array,function (key,f) {
                    dateStr.push(f.month);
                    feeCountStr.push(f.monthAmount);
                })
                // 基于准备好的dom，初始化echarts实例
                var myChartMonth = echarts.init(document.getElementById('monthDataContent'));
                // 指定图表的配置项和数据
                var option = {
                    grid: {
                        top:'20',
                        left: '0',   //图表距边框的距离
                        right: '0',
                        bottom: '0',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'category',
                        /*boundaryGap: false,*/

                        axisLabel: {
                            textStyle: {
                                color:'#333',
                                fontSize: 12,
                            },
                        },
                        axisTick:{
                            show:false  //去掉y轴刻度线
                        },

                        //坐标轴颜色
                        axisLine:{
                            show:true,
                            lineStyle: {
                                color: 'rgba(0, 0, 0, 0.45)',
                                width: '1'
                            }
                        },
                        data: dateStr
                    },
                    yAxis: [
                        {
                            type: 'value',
                            min:0,
                            max:result.intervalData.max,
                            interval:result.intervalData.interval,
                            splitLine: {
                                show: true ,
                                lineStyle: {
                                    color: '#eee',
                                    width: '1'
                                }
                            },
                            axisLabel: {
                                textStyle: {
                                    color:'#333',
                                    fontSize: 12,
                                },

                            },

                            axisTick:{
                                show:false  //去掉y轴刻度线
                            },
                            //坐标轴颜色
                            axisLine:{
                                show:false,
                            },
                        }
                    ],
                    series: [
                        {
                            name:'',
                            type:'line',
                            itemStyle : {
                                normal : {
                                    barBorderRadius:[2, 2, 0, 0],
                                    label: {
                                        show: true,//是否展示
                                        position: 'top',
                                        textStyle: {
                                            fontSize: 12,
                                            color:'#333',
                                        }
                                    },
                                    color: 'rgba(28, 148, 154, 1)'
                                },

                            },
                            areaStyle: {
                                normal: {
                                    //前四个参数代表位置 左下右上，如下表示从上往下渐变色 紫色到暗蓝色，
                                    color: new echarts.graphic.LinearGradient(
                                        0, 0, 0, 1,
                                        [
                                            { offset: 0, color: 'rgba(28, 148, 154, 1)' },
                                            { offset: 1, color: 'rgba(28, 148, 154, 0)' }
                                        ]
                                    )
                                }
                            },
                            data: feeCountStr
                        },]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChartMonth.setOption(option);
                $("div#monthDataContent").css("width","auto");
                $(window).resize(function() {
                    myChartMonth.resize();
                });
            }
        }
    })
}
//获取欠费人员信息列表
function obtainOwningPayUserDataInfo(pensionNo,maxSize){
    $.ajax({
        url:getRootPath_web()+'statistics/obtainOwningMoneyUserData',
        type:'post',
        dataType:'json',
        data:{"pensionNo":pensionNo,"maxSize":maxSize},
        success:function (result) {
            if(result.code=='0000'){
                var userStr = "";
                if(result.totalSize>0){
                    $.each(result.array,function (key,u) {
                        if(u.colorFlag=='3'){
                            userStr+="<li class=\"case-list-btn red\">";
                            userStr+="<p>"+u.USER_NAME+"</p>";
                            userStr+="<p><span class=\"border-red\">"+u.pensionAddress+"</span></p>";
                            userStr+="</li>";
                        }else if(u.colorFlag=='2'){
                            userStr+="<li class=\"case-list-btn yellow\">";
                            userStr+="<p>"+u.USER_NAME+"</p>";
                            userStr+="<p><span class=\"border-yellow\">"+u.pensionAddress+"</span></p>";
                            userStr+="</li>";
                        }else {
                            userStr+="<li>";
                            userStr+="<p>"+u.USER_NAME+"</p>";
                            userStr+="<p><span>"+u.pensionAddress+"</span></p>";
                            userStr+="</li>";
                        }
                    })
                }else{
                    userStr+="<li><div class='emptyDiv'>暂无欠费人员信息</div></li>";
                }
                if(maxSize>0){
                    $("#owningMoneyData").empty();
                    $("#owningMoneyData").append(userStr);
                }else{
                    var contentStr= "<div class=\"pop-up\">";
                    contentStr+="<div class=\"pop-happy\">";
                    contentStr+="<div class=\"pop-title relative overflow mb15px\">";
                    contentStr+="<span class=\"ml15px\">欠费情况</span>";
                    contentStr+="<p class=\"right cursor\"><img src='"+getRootPath_web()+"static/img/close_icon.png' class=\"block pop-close\"><p>";
                    contentStr+="</div>";
                    contentStr+="<div class=\"mt30px mb30px\">";
                    contentStr+="<div class=\"case-list-scroll border1px border-top0\" style=\"height: 400px; overflow: hidden;\">";
                    contentStr+="<nav class=\"add-box-scroll\">";
                    contentStr+="<ul class=\"case-list\">";
                    contentStr+=userStr;
                    contentStr+="</ul>";
                    contentStr+="</nav>";
                    contentStr+="</div>";
                    contentStr+="</div>";
                    contentStr+="</div>";
                    layui.use(['layer'], function() {
                        var layer = layui.layer;
                        layer.open({
                            type: 1,
                            title: false, //不显示标题栏
                            closeBtn: false,
                            area: [$('.pop-con').width() + 'px', ''],
                            shade: 0.6,
                            id: 'payCons', //设定一个id，防止重复弹出
                            /*,btn: ['确认支付']*/
                            btnAlign: 'c',
                            moveType: 1, //拖拽模式，0或者1
                            shadeClose: true, //设置允许点遮罩关闭
                            content: contentStr,
                            success: function() {
                                //关闭弹层
                                $(".pop-close").click(function() {
                                    layer.closeAll();
                                });
                            },

                        });
                    });
                }
            }
        }
    })
}
//查看所有欠费人员信息
function queryAllOwningPayUser(){
    var pensionNo =$("#pensionNo").val();
    obtainOwningPayUserDataInfo(pensionNo,0);
}
//查询楼苑分布图
function obtainBuildingInfoDetail(obj){
    var buildingNo = obj.id;
    $.ajax({
        url:getRootPath_web()+'statistics/obtainBuildingInfoDetail',
        type:'post',
        dataType:'json',
        data:{"buildingNo":buildingNo},
        success:function (result) {
            if(result.code=='0000'){
                var contentStr="<div class=\"pop-up\">";
                contentStr+= "<div class=\"pop-pandect-con\">";
                contentStr+="<div class=\"pop-title pop-title-happy relative overflow mb15px textCenter\">";
                contentStr+="<span>"+result.bName+"分布图</span>";
                contentStr+="<p class=\"right\">";
                contentStr+="<img src='"+getRootPath_web()+"/static/img/close_icon.png' class=\"block pop-close cursor\">";
                contentStr+="</p>";
                contentStr+="</div>";
                contentStr+="<div class=\"mt30px mb30px\">";
                contentStr+="<div style=\"height: 550px; overflow: hidden;\">";
                contentStr+="<div class=\"add-box-scroll\" style=\"margin-right: -17px;\">";
                contentStr+="<nav class=\"pandect-con \">";
                contentStr+="<ul>";
                contentStr+="<li class=\"mr10px \" style=\"flex: 1; height: 150px;\">";
                if(null!=result.bImg&&result.bImg!=''){
                    contentStr+="<div style=\"background-image: url("+result.bImg+"); padding-bottom: 150px;\" class=\"smallimg border-radius4 relative\">";
                }else {
                    contentStr+="<div style=\"background-image: url("+getRootPath_web()+"/static/img/defaultBuilding.png); padding-bottom: 150px;\" class=\"smallimg border-radius4 relative\">";
                }
                contentStr+="<p class=\"white\" style=\"position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); font-size: 30px;\">"+result.bName+"</p>";
                contentStr+="</div>";
                contentStr+="</li>";
                contentStr+="<li class=\"ml10px\" style=\"flex: 3;\">";
                contentStr+="<nav class=\"pandect-con pandect-con-one\">";
                contentStr+="<ul class=\"bed-stat-dl\">";
                contentStr+="<li class=\"border-radius4 border1px-ddd pad20px border-box\">";
                contentStr+="<dl>";
                contentStr+="<dt><img src='"+getRootPath_web()+"static/img/stat_01.png' >总床位数</dt>";
                contentStr+="<dd class=\"green\">"+result.totalBed+"</dd>";
                contentStr+="</dl>";
                contentStr+="<dl>";
                contentStr+="<dt><img src='"+getRootPath_web()+"static/img/stat_02.png' >入住数</dt>";
                contentStr+="<dd class=\"green\">"+result.usedBed+"</dd>";
                contentStr+="</dl>";
                contentStr+="<dl>";
                contentStr+="<dt><img src='"+getRootPath_web()+"static/img/stat_04.png' >入住率</dt>";
                contentStr+="<dd class=\"green\">"+result.occupancyRate+"</dd>";
                contentStr+="</dl>";
                contentStr+="</li>";
                contentStr+="</ul>";
                contentStr+="</nav>";
                contentStr+="</li>";
                contentStr+="</ul>";
                contentStr+="</nav>";
                if(result.floorCount>0){
                    $.each(result.floorArray,function (key,f) {
                        contentStr+="<article class=\"mt30px\">";
                        contentStr+="<div class=\"new-add-title happy-add-title relative overflow mb15px\"><span class=\"ml15px\">";
                        contentStr+=f.fName+"（入住"+f.fUseBedCount+"，空置"+f.fEmptyBedCount+"）";
                        contentStr+="</span></div>";
                        contentStr+="<nav class=\"pandect-con pandect-con-happy\">";
                        contentStr+="<ul>";
                        if(f.roomCount>0){
                            $.each(f.roomInfo,function (key,r) {
                                if(r.bedCount>0){
                                    contentStr+="<li class=\"border-radius4 border1px-ddd border-box mb10px\">";
                                    contentStr+="<h1 class=\"border-top-radius4 bgBlue-rgba\">"+r.roomName+"</h1>";
                                    contentStr+="<nav class=\"pandect-con\">";
                                    contentStr+="<ul>";
                                    $.each(r.bedInfo,function (key,b) {
                                        if(r.roomType=='102'){
                                            //如果房间用于其他用途
                                            contentStr+="<li>";
                                            contentStr+="<div>";
                                            contentStr+="<p>"+b.bedName+"</p>";
                                            contentStr+="</div>";
                                            contentStr+="<div>";
                                            contentStr+="<h2><img src='"+getRootPath_web()+"static/img/icon_cangku.png' alt=\"\">";
                                            contentStr+=r.roomUser+"</h2>";
                                            contentStr+="</div>";
                                            contentStr+="</li>";
                                        }else {
                                            //如果房间用于病房
                                            if(b.isEmpty=='0'){
                                                //如果该床位没有被使用
                                                contentStr+="<li>";
                                                contentStr+="<div>";
                                                contentStr+="<p>"+b.bedName+"</p>";
                                                contentStr+="</div>";
                                                contentStr+="<div>";
                                                contentStr+="<h2><img src='"+getRootPath_web()+"static/img/icon_kongzhi.png'>空置</h2>";
                                                contentStr+="</div>";
                                                contentStr+="</li>";
                                            }else if(b.isEmpty=='1'){
                                                //如果该床位已经住人
                                                contentStr+="<li>";
                                                contentStr+="<div>";
                                                contentStr+="<p>"+b.bedName+"</p>";
                                                contentStr+="</div>";
                                                contentStr+="<div>";
                                                if(null!=b.userMap){
                                                    if(b.userMap.cognition_status=='1'){
                                                        contentStr+="<p><span class=\"span-bgRed\">认知</span></p>";
                                                    }
                                                    contentStr+="<p>"+b.userMap.USER_NAME+"</p>";
                                                    contentStr+="<p>年龄:"+b.userMap.AGE+"</p>";
                                                    contentStr+="<p>护理:"+b.userMap.nursingName+"</p>";
                                                    contentStr+="<p>评估:"+b.userMap.assessmentName+"</p>";
                                                    contentStr+="</div>";
                                                    contentStr+="</li>";
                                                }
                                            } else{
                                                //如果该床位已被预订
                                                contentStr+="<li>";
                                                contentStr+="<div>";
                                                contentStr+="<p>"+b.bedName+"</p>";
                                                contentStr+="</div>";
                                                contentStr+="<div>";
                                                contentStr+="<h2 class='green'><img src='"+getRootPath_web()+"static/img/icon_kongzhi.png'>已预订</h2>";
                                                contentStr+="</div>";
                                                contentStr+="</li>";
                                            }
                                        }
                                    })
                                    contentStr+="</ul>";
                                    contentStr+="</nav>";
                                }
                            })
                        }
                        contentStr+="</ul>";
                        contentStr+="</nav>";
                        contentStr+="</article>";
                    })
                }
                contentStr+="</div>";
                contentStr+="</div>";
                contentStr+="</div>";
                contentStr+="</div>";
                contentStr+="</div>";
                layui.use(['layer'], function() {
                    var layer = layui.layer;
                    layer.open({
                        type: 1,
                        title: false, //不显示标题栏
                        closeBtn: false,
                        area: [$('.pop-con').width() + 'px', ''],
                        shade: 0.6,
                        id: 'payCons', //设定一个id，防止重复弹出
                        /*,btn: ['确认支付']*/
                        btnAlign: 'c',
                        moveType: 1, //拖拽模式，0或者1
                        shadeClose: true, //设置允许点遮罩关闭
                        content: contentStr,
                        success: function() {
                            //关闭弹层
                            $(".pop-close").click(function() {
                                layer.closeAll();
                            });
                        },
                    });
                });
            }
        }
    })
}
//气泡框展开收起
$('.prompt li:gt(4)').hide();
$('.prompt-btn').click(function() {
    if ($(this).find('img').attr('src') == 'img/select_arrow_down.png') {
        $(this).find('img').attr('src', 'img/select_arrow_up.png').siblings("span").text("收起");;

    } else {
        $(this).find('img').attr('src', 'img/select_arrow_down.png').siblings("span").text("更多");;
    }
    $('.prompt li:gt(4)').slideToggle(300);
})
$('.prompt').hide();
$('.tips').click(function(){
    $('.prompt').slideToggle(300);
})